/*
 * @lc app=leetcode.cn id=746 lang=javascript
 *
 * [746] 使用最小花费爬楼梯
 */

// @lc code=start
/**
 * @param {number[]} cost
 * @return {number}
 */
var minCostClimbingStairs = function (cost) {
  const stepLength = cost.length;
  // 易错初始条件
  const currentMinFee = [0, 0];
  for (let i = 2; i <= stepLength; i++)
    currentMinFee[i] = Math.min(
      currentMinFee[i - 1] + cost[i - 1],
      currentMinFee[i - 2] + cost[i - 2]
    );
  return currentMinFee[stepLength];
};
// @lc code=end
